<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css" media="all">

</head>
<body>
	<form class="layui-form" lay-filter="example" method="post">
		<div class="layui-form-item">
			<label class="layui-form-label">学生姓名</label>
			<div class="layui-input-block">
				<input type="text" name="stuname" lay-verify="title"
					autocomplete="off" placeholder="请输入修改后学生姓名" class="layui-input"
					id="stuname">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">年龄</label>
			<div class="layui-input-block">
				<input type="text" name="stuage" placeholder="请输入年龄"
					autocomplete="off" class="layui-input" id="stuage">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">单选框</label>
			<div class="layui-input-block">
				<input type="radio" name="sex" value="男" title="男" checked="" id="nan">
				<input type="radio" name="sex" value="女" title="女" id="nv">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-block">
				<input type="checkbox" checked="" name="open" lay-skin="switch"
					lay-filter="switchTest" lay-text="正常|禁用" id="cb">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block" id="layerDemo">
				<input type="button" value="提交" class="btn btn-default layui-btn"
					id="btn" data-method="offset" data-type="auto" />
			</div>
		</div>

	</form>
	<script src="layui/layui.js" charset="utf-8"></script>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script>
		var stuid;
		function child(obj) {
			/* console.log(obj);//获取父界面的传值 */
			$("#stuname").val(obj.stuname);
			$("#stuage").val(obj.stuage);
			if(obj.stusex=="女"){
				$("input:radio[name=sex][value='女']").attr("checked",true);
			}
			if(obj.status==0){
				$("#cb").attr("checked",false);
			}
			stuid = obj.stuid;
			layui.form.render();
		}
		layui.use([ 'form', 'layedit', 'laydate' ], function() {

			$("#btn").click(
					function() {
						$.ajax({
							url : "StudentServlet",
							data : {
								"op" : "update",
								"stuname" : $("#stuname").val(),
								"stuage" : $("#stuage").val(),
								"stuid" : stuid,
								"stusex" : $("input:radio[name=sex]:checked").val(),
								"status" : $("input[type='checkbox']").prop('checked')?1:0
							},
							success : function(data) {
								layer.msg(data, {
									icon : 1,
									time : 2000
								//2秒关闭（如果不配置，默认是3秒）
								}, function() {
									//关闭自己
									var index = parent.layer
											.getFrameIndex(window.name);
									parent.layer.close(index);
								});

								/* layer.msg(data);
								layer.closeAll('iframe'); */
							}
						});
					});
		});
	</script>
</body>
</html>